<!DOCTYPE HTML>
<html>
<head>
    <meta charset="UTF-8">
    <title>投票总览</title>
    <link rel="stylesheet" type="text/css" href="layui/css/layui.css">
    <style type="text/css">
        .layui-table-cell {
            height: 100%;
            max-width: 100%;
        }
    </style>
</head>
<body>

<div id="view" style="width: 800px; height: 600px;">

</div>



<script type="text/javascript" src="layui/layui.js"></script>
<script type="text/javascript" src="js/jquery-1.8.3.min.js"></script>
<script type="text/javascript" src="js/echarts.min.js"></script>
<script type="text/javascript">


    $.ajax({
        url:"admin-view/view",
        type:"get",
        dataType:"json",
        success:function (result) {
            var wait = result.data.wait;
            var run = result.data.run;
            var finish = result.data.finish;
            var chart = echarts.init(document.getElementById("view"));
            //通过setOption方法设置图表的选项
            chart.setOption({
                title: {
                    text: '投票活动总览',
                    left: 'center'
                },
                tooltip: {
                    trigger: 'item',
                    formatter: '{a} <br/>{b} : {c} ({d}%)'
                },
                legend: {
                    orient: 'vertical',
                    left: 'left',
                    data: ['未开始', '进行中', '已结束']
                },
                series: [
                    {
                        name: '活动数',
                        type: 'pie',
                        radius: '66%',
                        center: ['50%', '50%'],
                        data: [
                            {value: wait, name: '未开始'},
                            {value: run, name: '进行中'},
                            {value: finish, name: '已结束'}
                        ],
                        emphasis: {
                            itemStyle: {
                                shadowBlur: 10,
                                shadowOffsetX: 0,
                                shadowColor: 'rgba(0, 0, 0, 0.5)'
                            }
                        }
                    }
                ],
                color:['#ee6666','#8f93f6','#84be6e'],
            });
        }

    });
</script>


</body>
</html>